//
//  UIView+Line.m
//  Demo1222
//
//  Created by xx on 15/12/28.
//  Copyright © 2015年 HzB. All rights reserved.
//

#import "UIView+Line.h"

@implementation UIView (Line)

+ (instancetype)lineView{
    
    UIView *lineView = [[UIView alloc]init];
    lineView.backgroundColor = kLineViewColor;
    return lineView;
}

- (UIView *)addLineViewPositionType:(PositionType)positionType{
    
    UIView *lineView = [UIView lineView];
    [self addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.height.equalTo(@(linewViewHeight));
        if (positionType == kTop_Type) {
            make.top.equalTo(self.mas_top);
        }else
        {
            make.bottom.equalTo(self.mas_bottom);
        }
    }];
    return lineView;
}

- (UIView *)addLineViewLeftSpace:(CGFloat)leftSpace rightSpace:(CGFloat)rightSpace positionType:(PositionType)positionType
{
    UIView *lineView = [UIView lineView];
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).offset(leftSpace);
        make.right.equalTo(self.mas_right).offset(-rightSpace);
        make.height.equalTo(@(linewViewHeight));
        if (positionType == kTop_Type) {
            make.top.equalTo(self.mas_top);
        }else
        {
            make.bottom.equalTo(self.mas_bottom);
        }
    }];
    
    return lineView;
}


- (UIView *)addAplhaLeftSpace:(CGFloat)leftSpace rightSpace:(CGFloat)rightSpace positionType:(PositionType)positionType
{
    UIView *lineView = [UIView lineView];
    lineView.backgroundColor = [UIColor clearColor];
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).offset(leftSpace);
        make.right.equalTo(self.mas_right).offset(-rightSpace);
        make.height.equalTo(@(linewViewHeight));
        if (positionType == kTop_Type) {
            make.top.equalTo(self.mas_top);
        }else
        {
            make.bottom.equalTo(self.mas_bottom);
        }
    }];
    
    return lineView;
}


//加边框变角度
-(void)addViewCornerRudis:(CGFloat)corner andLineColor:(UIColor *)lineColor
              andIsCorner:(BOOL)isCorner{
    self.layer.borderColor = lineColor.CGColor;
    self.layer.borderWidth = 0.5;
    if (isCorner) {
        self.layer.cornerRadius = corner;
        self.layer.masksToBounds = YES;
    }
}

@end
